import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class demo1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            String[] ch = new String[n];
            for (int i = 0; i < n; i++) {
                ch[i] = in.next();
            }
            Stack<String> stack = new Stack<>();
            int num1 = 0;
            int num2 = 0;
            int ret = 0;
            for (int i = 0; i < n; i++) {
                if (!ch[i].equals("+") && !ch[i].equals("-")  && !ch[i].equals("*") && !ch[i].equals("/")) {
                    stack.add(ch[i]);
                } else {
                    num2 = Integer.parseInt(stack.pop());
                    num1 = Integer.parseInt(stack.pop());
                    if (ch[i].equals("+")) {
                        ret = num1 + num2;
                        stack.add(ret + "");
                    } else if (ch[i].equals("-")) {
                        ret = num1 - num2;
                        stack.add(ret + "");
                    } else if (ch[i].equals("*")) {
                        ret = num1 * num2;
                        stack.add(ret + "");
                    }
                    else if (ch[i].equals("/")){
                        ret = num1 / num2;
                        stack.add(ret + "");
                    }
                }
            }
            System.out.println(stack.pop());
        }
    }
}